MacHTTP Relative URLs

You can use URLs that are relative to your root. For example: if I have a document on my server "http://some.where.foo/folder/machttp/doc.html" I can specify a link to my home page "http://some.where.foo/Default.html" as simply "/Default.html".

Assume your document root contains things named file_0, dir_1, and dir_2. dir_1 contains file_1 and dir_2 contains file_2. file_0 references either of the other 2 files in subdirectories with the expected partial URL of "dir_1/file_1" or "dir_2/file_2".

file_1 can reference file_2 with the URL "/dir_2/file_2" and vice versa. file_1 and file_2 can reference file_0 with the URL "/file_0". All you save in most cases is respecifying the host and protocol. However, this is enough to make document trees portable in most cases.

There is no shorthand reference for the parent directory. If the file being referenced isn't a sibling in the same folder or a child in a sub-folder, the minimum URL must specify the full path to the file (i.e., when the referenced file lives above the referencing files level in the directory hierarchy, or in a different branch of the tree altogether.) As mentioned, protocols and hosts can generally be omitted.

This technique really relies on the good graces of the client to work, as the semantics of the path portion of a URL are REALLY supposed to be ignored by the client. URL paths are only supposed to be meaningful to the server on the host specified in the URL. Clients that interpret URLs by parsing path names are doomed to failure when more complex URLs are developed that aren't based on Unix path name syntax.


4/20/94 - gneufeld
MacHTTP Contents